/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package de.hsmannheim.pepa.patientenportal.apanwep.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import de.hsmannheim.pepa.patientenportal.apanwep.model.objects;
import de.hsmannheim.pepa.patientenportal.apanwep.model.objectsModel;
import de.hsmannheim.pepa.patientenportal.apanwep.model.objectsSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the objects service. Represents a row in the &quot;objects&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link de.hsmannheim.pepa.patientenportal.apanwep.model.objectsModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link objectsImpl}.
 * </p>
 *
 * @author Cedric Nana
 * @see objectsImpl
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.objects
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.objectsModel
 * @generated
 */
@JSON(strict = true)
public class objectsModelImpl extends BaseModelImpl<objects>
	implements objectsModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a objects model instance should use the {@link de.hsmannheim.pepa.patientenportal.apanwep.model.objects} interface instead.
	 */
	public static final String TABLE_NAME = "objects";
	public static final Object[][] TABLE_COLUMNS = {
			{ "ID", Types.BIGINT },
			{ "objectname", Types.VARCHAR },
			{ "objectid", Types.VARCHAR },
			{ "objecttypecode", Types.BIGINT },
			{ "objecttypecoderole", Types.BIGINT },
			{ "objectidtypecode_id", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table objects (ID LONG not null primary key,objectname VARCHAR(75) null,objectid VARCHAR(75) null,objecttypecode LONG,objecttypecoderole LONG,objectidtypecode_id LONG)";
	public static final String TABLE_SQL_DROP = "drop table objects";
	public static final String ORDER_BY_JPQL = " ORDER BY objects.objectID ASC";
	public static final String ORDER_BY_SQL = " ORDER BY objects.ID ASC";
	public static final String DATA_SOURCE = "myDataSource";
	public static final String SESSION_FACTORY = "mySessionFactory";
	public static final String TX_MANAGER = "myTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.objects"),
			false);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.objects"),
			false);
	public static final boolean COLUMN_BITMASK_ENABLED = false;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static objects toModel(objectsSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		objects model = new objectsImpl();

		model.setObjectID(soapModel.getObjectID());
		model.setObjectname(soapModel.getObjectname());
		model.setObject_ID(soapModel.getObject_ID());
		model.setObjecttypecode(soapModel.getObjecttypecode());
		model.setObjecttypecoderole(soapModel.getObjecttypecoderole());
		model.setObjectidtypecode_id(soapModel.getObjectidtypecode_id());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<objects> toModels(objectsSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<objects> models = new ArrayList<objects>(soapModels.length);

		for (objectsSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.de.hsmannheim.pepa.patientenportal.apanwep.model.objects"));

	public objectsModelImpl() {
	}

	@Override
	public long getPrimaryKey() {
		return _objectID;
	}

	@Override
	public void setPrimaryKey(long primaryKey) {
		setObjectID(primaryKey);
	}

	@Override
	public Serializable getPrimaryKeyObj() {
		return _objectID;
	}

	@Override
	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Class<?> getModelClass() {
		return objects.class;
	}

	@Override
	public String getModelClassName() {
		return objects.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("objectID", getObjectID());
		attributes.put("objectname", getObjectname());
		attributes.put("object_ID", getObject_ID());
		attributes.put("objecttypecode", getObjecttypecode());
		attributes.put("objecttypecoderole", getObjecttypecoderole());
		attributes.put("objectidtypecode_id", getObjectidtypecode_id());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long objectID = (Long)attributes.get("objectID");

		if (objectID != null) {
			setObjectID(objectID);
		}

		String objectname = (String)attributes.get("objectname");

		if (objectname != null) {
			setObjectname(objectname);
		}

		String object_ID = (String)attributes.get("object_ID");

		if (object_ID != null) {
			setObject_ID(object_ID);
		}

		Long objecttypecode = (Long)attributes.get("objecttypecode");

		if (objecttypecode != null) {
			setObjecttypecode(objecttypecode);
		}

		Long objecttypecoderole = (Long)attributes.get("objecttypecoderole");

		if (objecttypecoderole != null) {
			setObjecttypecoderole(objecttypecoderole);
		}

		Long objectidtypecode_id = (Long)attributes.get("objectidtypecode_id");

		if (objectidtypecode_id != null) {
			setObjectidtypecode_id(objectidtypecode_id);
		}
	}

	@JSON
	@Override
	public long getObjectID() {
		return _objectID;
	}

	@Override
	public void setObjectID(long objectID) {
		_objectID = objectID;
	}

	@JSON
	@Override
	public String getObjectname() {
		if (_objectname == null) {
			return StringPool.BLANK;
		}
		else {
			return _objectname;
		}
	}

	@Override
	public void setObjectname(String objectname) {
		_objectname = objectname;
	}

	@JSON
	@Override
	public String getObject_ID() {
		if (_object_ID == null) {
			return StringPool.BLANK;
		}
		else {
			return _object_ID;
		}
	}

	@Override
	public void setObject_ID(String object_ID) {
		_object_ID = object_ID;
	}

	@JSON
	@Override
	public long getObjecttypecode() {
		return _objecttypecode;
	}

	@Override
	public void setObjecttypecode(long objecttypecode) {
		_objecttypecode = objecttypecode;
	}

	@JSON
	@Override
	public long getObjecttypecoderole() {
		return _objecttypecoderole;
	}

	@Override
	public void setObjecttypecoderole(long objecttypecoderole) {
		_objecttypecoderole = objecttypecoderole;
	}

	@JSON
	@Override
	public long getObjectidtypecode_id() {
		return _objectidtypecode_id;
	}

	@Override
	public void setObjectidtypecode_id(long objectidtypecode_id) {
		_objectidtypecode_id = objectidtypecode_id;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			objects.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public objects toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (objects)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		objectsImpl objectsImpl = new objectsImpl();

		objectsImpl.setObjectID(getObjectID());
		objectsImpl.setObjectname(getObjectname());
		objectsImpl.setObject_ID(getObject_ID());
		objectsImpl.setObjecttypecode(getObjecttypecode());
		objectsImpl.setObjecttypecoderole(getObjecttypecoderole());
		objectsImpl.setObjectidtypecode_id(getObjectidtypecode_id());

		objectsImpl.resetOriginalValues();

		return objectsImpl;
	}

	@Override
	public int compareTo(objects objects) {
		long primaryKey = objects.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof objects)) {
			return false;
		}

		objects objects = (objects)obj;

		long primaryKey = objects.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<objects> toCacheModel() {
		objectsCacheModel objectsCacheModel = new objectsCacheModel();

		objectsCacheModel.objectID = getObjectID();

		objectsCacheModel.objectname = getObjectname();

		String objectname = objectsCacheModel.objectname;

		if ((objectname != null) && (objectname.length() == 0)) {
			objectsCacheModel.objectname = null;
		}

		objectsCacheModel.object_ID = getObject_ID();

		String object_ID = objectsCacheModel.object_ID;

		if ((object_ID != null) && (object_ID.length() == 0)) {
			objectsCacheModel.object_ID = null;
		}

		objectsCacheModel.objecttypecode = getObjecttypecode();

		objectsCacheModel.objecttypecoderole = getObjecttypecoderole();

		objectsCacheModel.objectidtypecode_id = getObjectidtypecode_id();

		return objectsCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{objectID=");
		sb.append(getObjectID());
		sb.append(", objectname=");
		sb.append(getObjectname());
		sb.append(", object_ID=");
		sb.append(getObject_ID());
		sb.append(", objecttypecode=");
		sb.append(getObjecttypecode());
		sb.append(", objecttypecoderole=");
		sb.append(getObjecttypecoderole());
		sb.append(", objectidtypecode_id=");
		sb.append(getObjectidtypecode_id());
		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("de.hsmannheim.pepa.patientenportal.apanwep.model.objects");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>objectID</column-name><column-value><![CDATA[");
		sb.append(getObjectID());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>objectname</column-name><column-value><![CDATA[");
		sb.append(getObjectname());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>object_ID</column-name><column-value><![CDATA[");
		sb.append(getObject_ID());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>objecttypecode</column-name><column-value><![CDATA[");
		sb.append(getObjecttypecode());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>objecttypecoderole</column-name><column-value><![CDATA[");
		sb.append(getObjecttypecoderole());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>objectidtypecode_id</column-name><column-value><![CDATA[");
		sb.append(getObjectidtypecode_id());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = objects.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			objects.class
		};
	private long _objectID;
	private String _objectname;
	private String _object_ID;
	private long _objecttypecode;
	private long _objecttypecoderole;
	private long _objectidtypecode_id;
	private objects _escapedModel;
}